package com.lanqiao.gxnushop.mapper;

import com.lanqiao.gxnushop.entity.Sellers;
import com.lanqiao.gxnushop.valueObject.SellerNeed;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

@Mapper
public interface SellersMapper {
    /** 新增seller
     * 出入参数  seller
     * 返回值  boolean*/
    @Insert("insert into sellers(sellerId,name,sfz,email,phone,address,zcsj,state) values (#{sellerId},#{name},#{sfz},#{email},#{phone},#{address},now(),'0')")
    boolean add(Sellers sellers);


    /**注册时同步 将主键 插入 seller 表*/
    @Insert("insert into sellers(sellerId,zcsj) values(#{sellerId},now())")
    boolean addSeller(String sellerId);


    /**删除卖家，通过卖家Id删除  传入参数  sellerId*/
    @Delete("delete from sellers where sellerId = #{sellerId}")
    boolean delete (String sellerId);


    /**注册成为卖家时   管理员审核通过后，将状态state置为1，表示注册卖家成功*/
    @Update("update sellers set state='1' where sellerId = #{sellerId}")
    boolean updateState (String sellerId);

    /**更新卖家信息  出入参数为 seller */
    @Update("update sellers set name=#{name},sfz=#{sfz},email=#{email},phone=#{phone},address=#{address} where sellerId=#{sellerId}")
    boolean update (Sellers sellers);

    /**通过卖家Id查找卖家信息*/
    @Select("select * from sellers where sellerId = #{sellerId}")
    Sellers select (String sellerId);

    /**通过（条件: name，state ）查找卖家卖家信息*/
    @SelectProvider(type = SellersMapperProvide.class,method = "getListString")
    ArrayList<Sellers> list  (Sellers sellers);


    /**商家需要的订单信息*/
    @SelectProvider(type = SellersMapperProvide.class,method = "getOrderListString")
    ArrayList<SellerNeed> getOrderList(SellerNeed sellerNeed);

    /**更新用户头像*/
    @Update("update sellers set yhtx=#{yhtx} where sellerId=#{sellerId}")
    boolean updateYhtx(Sellers sellers);
}
